$().ready(function() {
	jQuery.validator.addMethod("isPhone", function(value, element) {       
		var length = value.length;   
		var mobile = /^[1][34578][0-9]{9}$/;   
		return this.optional(element) || (length == 11 && mobile.test(value));       
	}, "请填写正确的手机号码");
	
	$("form").validate({
		errorPlacement: function(error, element) {
			$( element )
				.closest( "form" )
					.find( "label[for='" + element.attr( "id" ) + "']" )
						.append( error );
		},
		errorElement: "span",
		rules: {
			newpwd: {
				equalTo: "#password"
			},
			phone:{   
				required: true,   
				isPhone: true  
			}
		},
		messages: {
			user: {
				required: "不能为空！",
				minlength: "请输入2~10的字符数！",
				maxlength: "请输入2~10的字符数！"
			},
			realname: {
				required: "不能为空！",
				minlength: "不能少于2个字符"
			},
			idcard: {
				required: "不能为空！",
				minlength: "不能少于15个字符",
				maxlength: "不能超出18个字符"
			},
			bankcard: {
				required: "不能为空！",
				minlength: "不能少于14个字符"
			},
			payinfo: {
				required: "不能为空！"
			},
			notes: {
				required: "不能为空！"
			},
			password: {
				required: "不能为空！",
				minlength: "请输入6~12的字符数！",
				maxlength: "请输入6~12的字符数！"
			},
			newpwd: {
				required: "不能为空！",
				equalTo: "请重复输入密码"
			},
			phone:{   
				required: "请输入您的手机号",   
				isPhone: "请输入有效的手机号码"  
			} 
			
		}
	});
});

